/*
							Copyright (C) 2010  Alourien Team
									
						This file is part of the Alourien Engine.

    The Alourien Engine is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    The Alourien Engine is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with the Alourien Engine.  If not, see <http://www.gnu.org/licenses/>.
	
 *File Name: COurTimer.cpp
 *Programmer: Manuel Cuellar
 *Date of Last Update: 9/30/2010
 *
 *Purpose: This timer class provides simple features that will be used
 * in the engine, such as a stopwatch
 *
 *Basic Info: Please do not modify any functions without permission
 *
 *UPDATES:
 *
 *
 *
 */

#include "COurTimer.h"

namespace Alourien
{
	COurTimer::COurTimer(void)
	{
		timer_start = timeGetTime();
		reset();
	}

	COurTimer::~COurTimer(void)
	{
	}

	DWORD COurTimer::getTimer()
	{
		return (DWORD)(timeGetTime());
	}

	DWORD COurTimer::getCurrentTime()
	{
		return (DWORD)(timeGetTime() - timer_start);
	}

	void COurTimer::sleep(int ms)
	{
		DWORD start = getTimer();
		while(start + ms > getTimer());
	}

	void COurTimer::reset()
	{
		stopwatch_start = getTimer();
	}

	bool COurTimer::stopwatch(int ms)
	{
		if(timeGetTime() > stopwatch_start + ms)
		{
			stopwatch_start = getTimer();
			return true;
		}
		else
		{
			return false;
		}
	}
} //Namespace


